<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
<%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
<c:if test="${userList==null}">
	<c:redirect url="/servlet/UserManageServlet?fromPage=/Admin/User_List.jsp&act=userList"></c:redirect>
</c:if>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'User_List.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<c:url value="/Admin/styles/general.css" />" rel="stylesheet" type="text/css" />
	<link href="<c:url value="/Admin/styles/main.css" />" rel="stylesheet" type="text/css" />
    <script language="javascript">
		function pagingOnClick(num){
			if(num==1){
				searchForm.curPage.value=1;
			}
			if(num==2){
				searchForm.curPage.value=${curPage} - 1;
			}
			if(num==3){
				searchForm.curPage.value=${curPage} + 1;
			}
			if(num==4){
				searchForm.curPage.value=${pageCount};
			}
			searchForm.submit();
		}
		
		function userLockOnClick(suser,slock){
			location.href="<c:url value='/servlet/UserManageServlet?fromPage=/Admin/User_List.jsp&act=userList" + "&userLock=" + slock + "&suser=" + suser+" '/>";
		}
	</script>

  </head>
  
  <body>
   	<h1>
		<span><a href="#">Shop 管理中心</a>  - 会员列表 </span>
	</h1>
	<div class="form-div">
	  <form action="<c:url value="/servlet/UserManageServlet"/>" name="searchForm">
	    <img src="<c:url value="/Admin/images/icon_search.gif" />" width="26" height="22" border="0" alt="SEARCH" />&nbsp;用户名 &nbsp;
	    <input type="text" name="suser" value="${param.suser}" /> &nbsp;真实姓名 &nbsp;
	    <input type="text" name="sname" value="${param.sname}" />&nbsp;
	    <input type="submit" value=" 搜索 " class="button" />
	    <input type="hidden" name="act" value="userList" />
	    <input type="hidden" name="fromPage" value="/Admin/User_List.jsp" />
	    <input type="hidden" name="curPage" value="1" />
	  </form>
	</div>
	<div class="list-div" id="listDiv">
		<!--用户列表部分-->
		<table cellpadding="0" cellspacing="1">
		  <tr>
		    <th>用户名</th>
		    <th>真实姓名</th>
		    <th><a href="# ">邮件地址</a></th>
		    <th>电话号码</th>
		    <th><a href="#">注册日期</a></th>
		    <th>是否封号</th>
		    <th>操作</th>
		  </tr>
		  <c:forEach var="userBean" items="${userList}">
		    <tr>
		    <td align="center">${userBean.suser}</td>
		    <td align="center">${userBean.sname}</td>
		    <td align="center">${userBean.semail}</td>
		    <td align="center">${userBean.sphone}</td>
		    <td align="center">${userBean.dregdate}</td>
		    <c:choose>
		    <c:when test="${userBean.slock eq 0}">
		        <td align="center">正常</td>
		    	<td align="center"><a href="#" onclick="userLockOnClick('${userBean.suser}','1');return false;">封号</a></td>
		    </c:when>
		    <c:otherwise>
		        <td align="center" style="color:#FF0000;">已封号</td>
		    	<td align="center"><a href="#" onclick="userLockOnClick('${userBean.suser}','0');return false;">解封</a></td>
		    </c:otherwise>
		    </c:choose>
		 	</tr>
		  </c:forEach>
		    <tr>
		      <td align="right" nowrap="true" colspan="7" height="22px">
		            <div id="turn-page">
		        总计  <span id="totalRecords">${recordSize}</span>
		        个记录分为 <span id="totalPages">${pageCount}</span>
		        页当前第 <span id="pageCurrent">${curPage}</span>
		        页 
		        <span id="page-link">
		        <c:choose>
				<c:when test="${curPage==1}">
				<span>首页</span>
				<span>上一页</span>
				</c:when>
				<c:otherwise>
				<a href="#" onclick="pagingOnClick(1);return false;" >首页</a>
				<a href="#" onclick="pagingOnClick(2);return false;" >上一页</a>
				</c:otherwise>
				</c:choose>
				<c:choose>
				<c:when test="${curPage==pageCount}">
				<span>下一页</span>
				<span>尾页</span>
				</c:when>
				<c:otherwise>
				<a href="#" onclick="pagingOnClick(3);return false;" >下一页</a>
				<a href="#" onclick="pagingOnClick(4);return false;" >尾 页</a>
				</c:otherwise>
				</c:choose>
		        </span></div></td>
		  </tr>
		</table>
	</div>
	<div id="footer">版权所有 &copy;</div>
  </body>
</html>
